package com.neusoft.neuiotms.dcvm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.bizcore.web.dto.result.ResultListDTO;
import com.neusoft.neuiotms.dcvm.bean.StandardCiBean;
import com.neusoft.neuiotms.dcvm.bean.TopoBean;
import com.neusoft.neuiotms.dcvm.service.BusinessService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("业务模型管理")
@RestController
@RequestMapping(value = "/api/w/businesses")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @ApiOperation("获取业务模型拓扑数据")
    @GetMapping("/{code}")
    public ResultDTO<?> topo(@PathVariable final String code) {
        final TopoBean res = this.businessService.getBusinessTopo(code);
        return ResultDTO.success(res);
    }

    @ApiOperation("获取业务模型下所有实例详情")
    @GetMapping("/{code}/assets")
    public ResultListDTO<?> allAssetDetails(@PathVariable final String code) {
        final List<StandardCiBean> res = this.businessService.getBusinessAssets(code);
        return ResultListDTO.success(res);
    }

}
